package com.global.college.adapter;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.global.college.R;
import com.global.college.data.net.HomeGoodListBean;
import com.global.college.ui.activity.CourseDetailActivity;
import com.global.college.utils.LogUtils;

/**
 * 精选-免费好课
 */
public class FreeCourseAdapter extends BaseQuickAdapter<HomeGoodListBean.GoodListBean, BaseViewHolder> {

    public FreeCourseAdapter() {
        super(R.layout.item_free_course);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomeGoodListBean.GoodListBean bean) {
        if (bean.getClassModel() == null){
            LogUtils.i("未获取到课程信息");
            return;
        }
        helper.setText(R.id.tv_class_name, bean.getGoodName());
        helper.setText(R.id.tv_class_hour, bean.getClassModel().getClassNum()+"课时");
        helper.setText(R.id.tv_class_time, bean.getClassModel().getClassDuration()+"分钟");

        ImageView iv = helper.getView(R.id.iv_lesson_pic);
        Glide.with(mContext).load(bean.getClassModel().getClassCover()).into(iv);
        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mContext.startActivity(new Intent(mContext, CourseDetailActivity.class)
                        .putExtra("classId",bean.getClassModel().getClassId())
                        .putExtra("goodId",bean.getGoodId()));
            }
        });
    }

}
